package com.masterclient.app.modules.order;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.eoner.baselibrary.bean.goods.PromotionBean;
import com.eoner.baselibrary.bean.order.CheckRefundBean;
import com.eoner.baselibrary.bean.order.OrderDetailBean;
import com.eoner.baselib.utils.notify.RxBus;
import com.eoner.baselibrary.utils.GlideUtil;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselibrary.utils.ViewTransformUtil;
import com.eoner.common.config.Config;
import com.eoner.managerlibrary.router.AroutePath;
import com.eoner.managerlibrary.sobot.SobotManager;
import com.eoner.managerlibrary.user.UserDataManager;
import com.masterclient.app.BaseActivity;
import com.masterclient.app.R;
import com.masterclient.app.base.ConfirmDialog;
import com.masterclient.app.base.ProgressLoginDialog;
import com.masterclient.app.modules.aftersale.AfterSaleDetailActivity;
import com.masterclient.app.modules.aftersale.ChooseAfterSaleActivity;
import com.masterclient.app.modules.aftersale.ReturnGoodsActivity;
import com.masterclient.app.modules.aftersale.ReturnMoneyActivity;
import com.masterclient.app.modules.goods.newpage.activity.NewCommodityDetailActivity;
import com.masterclient.app.modules.order.contract.OrderDetailContract;
import com.masterclient.app.modules.order.contract.OrderDetailPresenter;
import com.masterclient.app.utils.CommonUtil;
import com.masterclient.app.widget.PriceIntegralLayout;
import com.sobot.chat.SobotApi;
import com.sobot.chat.api.enumtype.SobotChatTitleDisplayMode;
import com.sobot.chat.api.model.Information;
import com.tbruyelle.rxpermissions2.RxPermissions;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

import static com.masterclient.app.R.id.tv_invoice_name;

//import com.sobot.chat.api.model.OrderCardContentModel;

/**
 * 作者：sean
 * 创建时间：2017/7/27 18:28
 * 功能说明：订单详情
 */
@Route(path = AroutePath.ORDER_DETAIL_ACTIVITY)
public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> implements OrderDetailContract.View {


    @BindView(R.id.rl_back)
    RelativeLayout rlBack;
    @BindView(R.id.rl_message)
    FrameLayout rlMessage;
    @BindView(R.id.rl_head)
    RelativeLayout rlHead;
    @BindView(R.id.tv_order_status)
    TextView tvOrderStatus;
    @BindView(R.id.tv_remain_time)
    TextView tvRemainTime;
    @BindView(R.id.tv_user_name)
    TextView tvUserName;
    @BindView(R.id.tv_tel)
    TextView tvTel;
    @BindView(R.id.tv_address)
    TextView tvAddress;
    @BindView(R.id.tv_remark)
    TextView tvRemark;
    @BindView(R.id.tv_shop_name_tag)
    TextView tvShopNameTag;
    @BindView(R.id.tv_shop_name)
    TextView tvShopName;
    @BindView(R.id.iv_shop_icon)
    ImageView ivShopIcon;
    @BindView(R.id.ll_shop_container)
    LinearLayout llShopContainer;
    @BindView(R.id.tv_invoice_type)
    TextView tvInvoiceType;
    @BindView(R.id.ll_invoice_type)
    LinearLayout llInvoiceType;
    @BindView(tv_invoice_name)
    TextView tvInvoiceName;
    @BindView(R.id.ll_invoice_taitou)
    LinearLayout llInvoiceTaitou;
    @BindView(R.id.tv_invoice_company)
    TextView tvInvoiceCompany;
    @BindView(R.id.ll_invoice_company)
    LinearLayout llInvoiceCompany;
    @BindView(R.id.tv_invoice_address)
    TextView tvInvoiceAddress;
    @BindView(R.id.ll_invoice_address)
    LinearLayout llInvoiceAddress;
    @BindView(R.id.tv_invoice_id)
    TextView tvInvoiceId;
    @BindView(R.id.ll_invoice_id)
    LinearLayout llInvoiceId;
    @BindView(R.id.tv_invoice_bank)
    TextView tvInvoiceBank;
    @BindView(R.id.ll_invoice_bank)
    LinearLayout llInvoiceBank;
    @BindView(R.id.tv_invoice_bank_num)
    TextView tvInvoiceBankNum;
    @BindView(R.id.ll_bank_num)
    LinearLayout llBankNum;
    @BindView(R.id.tv_invoice_email)
    TextView tvInvoiceEmail;
    @BindView(R.id.ll_invoice_email)
    LinearLayout llInvoiceEmail;
    @BindView(R.id.ll_invoice)
    LinearLayout llInvoice;
    @BindView(R.id.tv_order_no)
    TextView tvOrderNo;
    @BindView(R.id.view_vip)
    View viewVip;
    @BindView(R.id.iv_icon)
    ImageView ivIcon;
    @BindView(R.id.tv_des)
    TextView tvDes;
    @BindView(R.id.tv_update)
    TextView tvUpdate;
    @BindView(R.id.iv_right_icon)
    ImageView ivRightIcon;
    @BindView(R.id.ll_card_container)
    LinearLayout llCardContainer;
    @BindView(R.id.view_divide_card)
    View viewDivideCard;
    @BindView(R.id.tv_card_des)
    TextView tvCardDes;
    @BindView(R.id.tv_pay_way)
    TextView tvPayWay;
    @BindView(R.id.tv_order_time)
    TextView tvOrderTime;
    @BindView(R.id.view_order_type)
    View viewOrderType;
    @BindView(R.id.tv_good_info)
    TextView tvGoodInfo;
    @BindView(R.id.line_remark)
    View lineRemark;
    @BindView(R.id.ll_remark)
    LinearLayout llRemark;
    @BindView(R.id.iv_state)
    ImageView ivState;
    @BindView(R.id.ll_shop)
    LinearLayout llShop;
    @BindView(R.id.iv_unread)
    ImageView ivUnread;
    @BindView(R.id.tv_offline)
    TextView tvOffline;
    @BindView(R.id.ll_address)
    LinearLayout llAddress;
    @BindView(R.id.view_freight)
    RelativeLayout viewFreight;

    OrderDetailBean.DataBean dataBean;
    CountDownTimer timer;
    RxPermissions rxPermissions;
    @BindView(R.id.tv_all_price)
    TextView tvAllPrice;
    @BindView(R.id.tv_freight)
    TextView tvFreight;
    @BindView(R.id.tv_discount_num)
    TextView tvDiscountNum;
    @BindView(R.id.tv_red_pack)
    TextView tvRedPack;
    @BindView(R.id.tv_cash_count)
    TextView tvCashCount;
    @BindView(R.id.ll_final_pay)
    PriceIntegralLayout llFinalPay;
    @BindView(R.id.ll_promotion_discount)
    LinearLayout llPromotionDiscount;
    @BindView(R.id.tv_promotion_discount_num)
    TextView tvPromotionDiscountNum;
    @BindView(R.id.ll_discount)
    LinearLayout llDiscount;
    @BindView(R.id.ll_red_pack)
    LinearLayout llRedPack;
    @BindView(R.id.ll_cash_count)
    LinearLayout llCashCount;
    @BindView(R.id.tv_apply_aftersale)
    TextView tvApplyAftersale;

    @BindView(R.id.ll_gold_count)
    View ll_gold_count;
    @BindView(R.id.tv_gold_count)
    TextView tv_gold_count;

    @BindView(R.id.contact_seller)
    TextView contact_seller;
    @BindView(R.id.tv_current_order)
    TextView tvCurrentOrder;
    @BindView(R.id.order_detail_bg)
    RelativeLayout orderDetailBg;
    @BindView(R.id.tv_purchase_desc)
    TextView tvPurchaseDesc;
    @BindView(R.id.rl_shop_layout)
    RelativeLayout rlShopLayout;
    @BindView(R.id.fl_custody_order)
    FrameLayout flCustodyOrder;
    @BindView(R.id.layout_pick_good)
    View layoutPickGood;
    @BindView(R.id.tv_pick_good_type)
    TextView tvPickGoodType;
    @BindView(R.id.layout_pick_good_order)
    View layoutPickGoodOrder;
    @BindView(R.id.tv_pick_good_order)
    TextView tvPickGoodOrder;

    private RxBus rxBus;
    String order_no,fromType;
    private ConfirmDialog refundDialog;
    private ConfirmDialog dialog;

    String sh_sobot_app_key = "";
    private String sh_sobot_flow_company_id;
    private String sh_sobot_flow_group_id;
    private String applyType;
    private OrderDetailBean.DataBean.ShProductsBean productsBean;
    private String fansId;
    private ProgressLoginDialog progressLoginDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_detail);
        ButterKnife.bind(this);

//        tvKefu.setTypeface(iconfont);
        rxBus = RxBus.$();

        rxPermissions = new RxPermissions(this);
        progressLoginDialog = new ProgressLoginDialog(this);
//        Utils.setDin(tvAllPrice, this);
//        Utils.setDin(tvFreight, this);
//        Utils.setDin(tvDiscountNum, this);
//        Utils.setDin(tvRedPack, this);
//        Utils.setDin(tvCashCount, this);
//        Utils.setDin(tvFinalPay, this);

        rxBus.OnEvent(rxBus.register(Config.MSG_UNREAD), new Consumer<Object>() {
            @Override
            public void accept(@NonNull Object o) throws Exception {
                if (Config.UNREAD > 0) {
                    ivUnread.setVisibility(View.VISIBLE);
                } else {
                    ivUnread.setVisibility(View.INVISIBLE);
                }
            }
        });
        order_no = getIntent().getStringExtra("order_no");
        fromType = getIntent().getStringExtra("from_type");
        if (fromType == null) {
            fromType = "";
        }
        if (("purchase".equals(fromType)||"sale".equals(fromType))){
            orderDetailBg.setBackgroundResource("sale".equals(fromType)?R.mipmap.sale_order_detail_head:R.mipmap.purchase_order_detail_head);
            llFinalPay.setPriceTextColor(Color.parseColor("#FF5000"));
        }
    }

    @Override
    protected void onResume() {
        mPresenter.getOrderDetail(order_no);
        super.onResume();
    }

    @Override
    public void showOrderDetail(OrderDetailBean.DataBean dataBean) {

        this.dataBean = dataBean;


//        flOrderFlow.setVisibility("22".equals(dataBean.getSh_type())?View.VISIBLE:View.GONE);

        flCustodyOrder.setVisibility(!TextUtils.isEmpty(dataBean.getSh_is_delivery())&&"1".equals(dataBean.getSh_is_delivery())?View.VISIBLE:View.GONE);
        //自提
        if("27".equals(dataBean.getSh_type())){
            layoutPickGood.setVisibility(View.VISIBLE);
            if (TextUtils.isEmpty(dataBean.getSh_order_relation_no())){
                tvPickGoodType.setText("提货方式：发到指定地点");
                layoutPickGoodOrder.setVisibility(View.GONE);
            }else {
                tvPickGoodType.setText("提货方式：让仓库代发给他人");
                layoutPickGoodOrder.setVisibility(View.VISIBLE);
                tvPickGoodOrder.setText("订单编号："+dataBean.getSh_order_relation_no());
            }
        }else {
            layoutPickGood.setVisibility(View.GONE);
        }

        if ("sale".equals(fromType)&&"26".equals(dataBean.getSh_type())){
            viewOrderType.setVisibility(View.VISIBLE);
        }else {
            viewOrderType.setVisibility(View.GONE);
        }


        tvCurrentOrder.setVisibility(TextUtils.isEmpty(dataBean.getSh_parent_order_no()) ? View.GONE : View.VISIBLE);

        tvAllPrice.setText(/*"¥" +*/ dataBean.getSh_product_total());
        tvFreight.setText(/*"¥" +*/ dataBean.getSh_shipping_amount());

        tvApplyAftersale.setText(dataBean.getSh_refund_button().getSh_is_refund_btn_txt());
        tvApplyAftersale.setVisibility("1".equals(dataBean.getSh_refund_button().getSh_is_refund_btn()) ? View.VISIBLE : View.GONE);

        if (!TextUtils.isEmpty(dataBean.getSh_promotion_deduction()) && Float.valueOf(dataBean.getSh_promotion_deduction()) > 0) {
            tvPromotionDiscountNum.setText(/*"-¥" +*/ dataBean.getSh_promotion_deduction());
            llPromotionDiscount.setVisibility(View.VISIBLE);
        } else {
            llPromotionDiscount.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(dataBean.getSh_coupon_discount_amount()) && Float.valueOf(dataBean.getSh_coupon_discount_amount()) > 0) {
            tvDiscountNum.setText(/*"-¥" +*/ dataBean.getSh_coupon_discount_amount());
            llDiscount.setVisibility(View.VISIBLE);
        } else {
            llDiscount.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(dataBean.getSh_bupiao()) && Float.valueOf(dataBean.getSh_bupiao()) > 0) {
            tvRedPack.setText(/*"-¥" + */dataBean.getSh_bupiao());
            llRedPack.setVisibility(View.VISIBLE);
        } else {
            llRedPack.setVisibility(View.GONE);
        }

        if (!TextUtils.isEmpty(dataBean.getSh_balance()) && Float.valueOf(dataBean.getSh_balance()) > 0) {
            tvCashCount.setText(/*"-¥" + */dataBean.getSh_balance());
            llCashCount.setVisibility(View.VISIBLE);
        } else {
            llCashCount.setVisibility(View.GONE);
        }

        if (!TextUtils.isEmpty(dataBean.getSh_deduction_amount()) && Float.valueOf(dataBean.getSh_deduction_amount()) > 0) {
            tv_gold_count.setText(/*"-¥" + */dataBean.getSh_deduction_amount());
            ll_gold_count.setVisibility(View.VISIBLE);
        } else {
            ll_gold_count.setVisibility(View.GONE);
        }

        if (dataBean.getSh_address() != null && !TextUtils.isEmpty(dataBean.getSh_address().getSh_receiver_name())) {
            llAddress.setVisibility(View.VISIBLE);
        } else {
            llAddress.setVisibility(View.GONE);
        }

        if ("3".equals(dataBean.getSh_order_type())) {
            viewFreight.setVisibility(View.GONE);
        } else {
            viewFreight.setVisibility(View.VISIBLE);
        }

        if (dataBean.getSh_tip() != null) {
            tvPurchaseDesc.setText(TextUtils.isEmpty(dataBean.getSh_tip().getSh_purchase())?"":dataBean.getSh_tip().getSh_purchase());
            tvPurchaseDesc.setVisibility(TextUtils.isEmpty(dataBean.getSh_tip().getSh_purchase())?View.GONE:View.VISIBLE);

        tvOrderStatus.setText(dataBean.getSh_tip().getSh_text());
//            tvRemainTime.setText(dataBean.getSh_tip().getSh_time());
        if (!"待付款".equals(dataBean.getSh_tip().getSh_label())) {
            if (!TextUtils.isEmpty(dataBean.getSh_tip().getSh_subtext())) {
                tvRemainTime.setText(dataBean.getSh_tip().getSh_subtext());
            } else if (!TextUtils.isEmpty(dataBean.getSh_tip().getSh_time()) && "8".equals(dataBean.getSh_status())) {//订单完成状态
                tvRemainTime.setText(dataBean.getSh_tip().getSh_time());
            } else {
                tvRemainTime.setVisibility(View.GONE);
            }
        } else {
            if (!TextUtils.isEmpty(dataBean.getSh_tip().getSh_time())) {
                timer = new CountDownTimer(Long.valueOf(dataBean.getSh_tip().getSh_time()) * 1000, 1000) {
                    @Override
                    public void onTick(long ms) {
                        Integer mi = 60 * 1000;
                        long min = ms / mi;
                        long sec = (ms - mi * min) / 1000;
                        tvRemainTime.setText("还剩" + min + "分" + sec + "秒自动关闭");
                    }

                    @Override
                    public void onFinish() {
                        if (tvRemainTime != null) {
                            tvRemainTime.setText("订单已关闭");
                        }
                        if (mPresenter != null) {
                            mPresenter.getOrderDetail(order_no);
                        }
                    }
                };
                timer.start();
            }
        }
            ViewTransformUtil.glideImageView(this, dataBean.getSh_tip().getSh_logo(), ivState,
    R.mipmap.defaults_1, ScreenUtils.dp2px(105), ScreenUtils.dp2px(95));

}

        if (dataBean.getSh_address() != null) {
            tvUserName.setText("收货人：" + dataBean.getSh_address().getSh_receiver_name());
            tvAddress.setText(dataBean.getSh_address().getSh_receiver_address());
            tvTel.setText(dataBean.getSh_address().getSh_receiver_phone());
        }

        if (TextUtils.isEmpty(dataBean.getSh_remark())) {
            llRemark.setVisibility(View.GONE);
            lineRemark.setVisibility(View.GONE);
        } else {
            tvRemark.setText("买家留言：\n" + dataBean.getSh_remark());
        }
        tvGoodInfo.setText(Html.fromHtml("共 " + dataBean.getSh_product_num() + " 件商品" + "   <font color=#333333>合计：</font>"));

//        tvFinalPay.setText(/*"¥" + */dataBean.getSh_should_pay_price());

        llFinalPay.setData((int) (Float.parseFloat(dataBean.getSh_grand_integral())
                - Float.parseFloat(dataBean.getSh_integral_deduction())) + "", dataBean.getSh_should_pay_price(), true);
        llFinalPay.floadSize(0.88f);
//        Utils.set_price_style(this,tvFinalPay,12,(int) (Float.parseFloat(dataBean.getSh_grand_integral())
//                - Float.parseFloat(dataBean.getSh_integral_deduction()))+"",dataBean.getSh_should_pay_price());
//        if (dataBean.getSh_grand_integral() != null && (Float.parseFloat(dataBean.getSh_grand_integral()) - Float.parseFloat(dataBean.getSh_integral_deduction())) > 0) {
//            int xx = (int) (Float.parseFloat(dataBean.getSh_grand_integral()) - Float.parseFloat(dataBean.getSh_integral_deduction()));
//            String point = xx + "";
//            String str1 = "金币";
//            String str2 = "+";
//            String str3 = "¥";
//            String money = dataBean.getSh_should_pay_price();
//            String content = point + str1 + str2 + str3 + money;
//            SpannableString spannableString = new SpannableString(content);
//            spannableString.setSpan(new RelativeSizeSpan(0.75f), point.length(), (point + str1).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//            spannableString.setSpan(new RelativeSizeSpan(0.75f), (point + str1 + str2).length(), (point + str1 + str2 + str3).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//            spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, point.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//            spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), (point + str1).length(), (point + str1 + str2 + str3 + money).length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//            tvFinalPay.setText(spannableString);
//        } else {
//            Utils.set_price_style(tvFinalPay, "¥" + dataBean.getSh_should_pay_price());
//        }

//        String discount_amount = "";
//        if (Float.valueOf(dataBean.getSh_discount_amount()) > 0) {
//            discount_amount = " 已优惠：¥" + dataBean.getSh_discount_amount();
//        }

//        tvDiscount.setText("(含运费¥" + dataBean.getSh_shipping_amount() + discount_amount + ")");

        tvRemark.setText("买家留言：\n" + dataBean.getSh_remark());
        tvOrderTime.setText(dataBean.getSh_create_at());
        tvOrderNo.setText(dataBean.getSh_order_no());

        if (!"1".equals(dataBean.getSh_is_my_sale())) {
            rlShopLayout.setVisibility(View.VISIBLE);
            tvShopName.setText(dataBean.getSh_seller().getSh_store_name());
//            if ("3".equals(dataBean.getSh_order_type())) {
//                ivShopIcon.setVisibility(View.GONE);
//            } else {
//                ivShopIcon.setVisibility(View.VISIBLE);
//            }
            //跨进商品Tag
            if (!TextUtils.isEmpty(dataBean.getSh_seller().getSh_seller_tag())) {
                tvShopNameTag.setVisibility(View.VISIBLE);
                tvShopNameTag.setText(dataBean.getSh_seller().getSh_seller_tag());
            } else {
                tvShopNameTag.setVisibility(View.GONE);
            }
        }else {
            rlShopLayout.setVisibility(View.GONE);
        }

        if (dataBean.getSh_seller() != null && !dataBean.getSh_seller().isSh_is_jump()){
//            ivShopIcon.setVisibility(View.GONE);
            contact_seller.setVisibility(View.GONE);
        }

        tvPayWay.setText(dataBean.getSh_payment());

        //会员非会员显示栏
        if (dataBean.getSh_upgrade_to_vip() != null) {
            OrderDetailBean.DataBean.ShUpGradeToVipBean upGradeToVipBean = dataBean.getSh_upgrade_to_vip();
            if ("0".equals(upGradeToVipBean.getSh_type())) {
                viewVip.setVisibility(View.GONE);
            } else if ("1".equals(upGradeToVipBean.getSh_type())) {
                //会员
                viewVip.setVisibility(View.VISIBLE);
                if (!TextUtils.isEmpty(upGradeToVipBean.getSh_icon())) {
                    ivIcon.setVisibility(View.VISIBLE);
                    GlideUtil.displayImage(this, upGradeToVipBean.getSh_icon(), ivIcon);
                }
                tvDes.setText(upGradeToVipBean.getSh_title());
                tvUpdate.setText("");
                ivRightIcon.setVisibility(View.VISIBLE);
            } else if ("2".equals(upGradeToVipBean.getSh_type())) {
                //非会员
                viewVip.setVisibility(View.VISIBLE);
                tvDes.setText(upGradeToVipBean.getSh_title());
                tvUpdate.setText("立即升级");
                ivIcon.setVisibility(View.GONE);
                ivRightIcon.setVisibility(View.VISIBLE);
            }
            viewVip.setOnClickListener(view -> {
                CommonUtil.goAnyWhere(this, upGradeToVipBean.getSh_target(), "", "", "", "");
            });
        } else {
            viewVip.setVisibility(View.GONE);
        }

        //卡号信息显示栏
        List<OrderDetailBean.DataBean.ShCardInfoBean> cardInfoList = dataBean.getSh_cardInfo();
        if (cardInfoList != null && cardInfoList.size() > 0) {
            llCardContainer.setVisibility(View.VISIBLE);
            viewDivideCard.setVisibility(View.VISIBLE);
            llCardContainer.removeAllViews();
            for (OrderDetailBean.DataBean.ShCardInfoBean cardInfoBean : cardInfoList) {
                View viewCard = View.inflate(mContext, R.layout.item_card_info, null);
                TextView tvCardNo = viewCard.findViewById(R.id.tv_card_no);
                TextView tvCardCopy = viewCard.findViewById(R.id.tv_card_copy);
                TextView tvCodeNo = viewCard.findViewById(R.id.tv_code_no);
                TextView tvCodeCopy = viewCard.findViewById(R.id.tv_code_copy);
                TextView tvTimeNo = viewCard.findViewById(R.id.tv_time_no);
                TextView tvTimeCopy = viewCard.findViewById(R.id.tv_time_copy);

                tvCardNo.setText(cardInfoBean.getSh_card_number());
                tvCodeNo.setText(cardInfoBean.getSh_card_pwd());
                tvTimeNo.setText(cardInfoBean.getSh_card_deadline());
                tvCardCopy.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                        // 将文本内容放到系统剪贴板里。
                        cm.setPrimaryClip(ClipData.newPlainText(null, cardInfoBean.getSh_card_number()));
                        showToast("已复制到粘贴板");
                    }
                });
                tvCodeCopy.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                        // 将文本内容放到系统剪贴板里。
                        cm.setPrimaryClip(ClipData.newPlainText(null, cardInfoBean.getSh_card_pwd()));
                        showToast("已复制到粘贴板");
                    }
                });
                tvTimeCopy.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                        // 将文本内容放到系统剪贴板里。
                        cm.setPrimaryClip(ClipData.newPlainText(null, cardInfoBean.getSh_card_deadline()));
                        showToast("已复制到粘贴板");
                    }
                });
                llCardContainer.addView(viewCard);
            }
        } else {
            llCardContainer.setVisibility(View.GONE);
            viewDivideCard.setVisibility(View.GONE);
        }

        //卡号底部信息显示栏
        if (!TextUtils.isEmpty(dataBean.getSh_card_des())) {
            tvCardDes.setVisibility(View.VISIBLE);
            tvCardDes.setText(Html.fromHtml(dataBean.getSh_card_des()));
        } else {
            tvCardDes.setVisibility(View.GONE);
        }

        sh_sobot_app_key = dataBean.getSh_seller().getSh_sobot_app_key();
        sh_sobot_flow_company_id = dataBean.getSh_seller().getSh_sobot_flow_company_id();
        sh_sobot_flow_group_id = dataBean.getSh_seller().getSh_sobot_flow_group_id();

        if (dataBean.getSh_invoice() != null && dataBean.getSh_invoice().getSh_type_label() != null) {
            tvInvoiceType.setText(dataBean.getSh_invoice().getSh_type_label());
            tvInvoiceName.setText(dataBean.getSh_invoice().getSh_name_type_label());
            if (TextUtils.isEmpty(dataBean.getSh_invoice().getSh_name())) {
                llInvoiceCompany.setVisibility(View.GONE);
            } else {
                tvInvoiceCompany.setText(dataBean.getSh_invoice().getSh_name());
            }
            if (TextUtils.isEmpty(dataBean.getSh_invoice().getSh_email())) {
                llInvoiceEmail.setVisibility(View.GONE);
            } else {
                tvInvoiceEmail.setText(dataBean.getSh_invoice().getSh_email());
            }

            if (TextUtils.isEmpty(dataBean.getSh_invoice().getSh_duty_paragraph())) {
                llInvoiceId.setVisibility(View.GONE);
            } else {
                tvInvoiceId.setText(dataBean.getSh_invoice().getSh_duty_paragraph());
            }
            if (TextUtils.isEmpty(dataBean.getSh_invoice().getSh_address())) {
                llInvoiceAddress.setVisibility(View.GONE);
            } else {
                tvInvoiceAddress.setText(dataBean.getSh_invoice().getSh_address());
            }
            if (TextUtils.isEmpty(dataBean.getSh_invoice().getSh_bank_name())) {
                llInvoiceBank.setVisibility(View.GONE);
            } else {
                tvInvoiceBank.setText(dataBean.getSh_invoice().getSh_bank_name());
            }
            if (TextUtils.isEmpty(dataBean.getSh_invoice().getSh_bank_number())) {
                llBankNum.setVisibility(View.GONE);
            } else {
                tvInvoiceBankNum.setText(dataBean.getSh_invoice().getSh_bank_number());
            }
        } else {
            llInvoice.setVisibility(View.GONE);
        }

        llShopContainer.removeAllViews();
        for (int i = 0; i < dataBean.getSh_products().size(); i++) {
            OrderDetailBean.DataBean.ShProductsBean shProductsBean = dataBean.getSh_products().get(i);
            View view = View.inflate(mContext, R.layout.item_good_order_detail, null);
            ViewHolder holder = new ViewHolder(view);
//            Utils.setDin(holder.tvPrice, this);

            //提货单
            if (!TextUtils.isEmpty(dataBean.getSh_type())&&"27".equals(dataBean.getSh_type())){
                holder.layoutPrice.setVisibility(View.GONE);
                holder.tvPickGoodNum.setVisibility(View.VISIBLE);
                holder.tvPickGoodNum.setText("提货数量 "+shProductsBean.getSh_buy_qty());
            }else {
                holder.layoutPrice.setVisibility(View.VISIBLE);
                holder.tvPickGoodNum.setVisibility(View.GONE);
            }
            if (!TextUtils.isEmpty(shProductsBean.getSh_custody_tip())){
                holder.layoutGoodDesc.setVisibility(View.VISIBLE);
                holder.tvGoodDesc.setText(shProductsBean.getSh_custody_tip());
            }else {
                holder.layoutGoodDesc.setVisibility(View.GONE);
            }

            ViewTransformUtil.glideImageView(this, shProductsBean.getSh_image(), holder.ivGood, R.mipmap.defaults,
                    ScreenUtils.dp2px(107), ScreenUtils.dp2px(107));

            holder.tvGosNum.setText("x" + shProductsBean.getSh_buy_qty());

            holder.tagPriceVip.setVisibility(shProductsBean.isSh_show_vip_price()?View.VISIBLE:View.GONE);
            if (shProductsBean.isSh_show_vip_price()){
                holder.llPrice.setData("",shProductsBean.getSh_vip_price());
            }else {
                holder.llPrice.setData((int) (Float.valueOf(shProductsBean.getSh_integral())
                        / Float.valueOf(shProductsBean.getSh_buy_qty())) + "", shProductsBean.getSh_price());
            }
//            Utils.set_price_style(this,holder.tvPrice,12,(int) (Float.valueOf(shProductsBean.getSh_integral())
//                    / Float.valueOf(shProductsBean.getSh_buy_qty()))+"",shProductsBean.getSh_price());
//            if (shProductsBean.getSh_integral() != null && Float.valueOf(shProductsBean.getSh_integral()) > 0) {
//                int temp = (int) (Float.valueOf(shProductsBean.getSh_integral()) / Float.valueOf(shProductsBean.getSh_buy_qty()));
//                String content = temp + " 金币";
//                SpannableString spannableString = new SpannableString(content);
//                spannableString.setSpan(new RelativeSizeSpan(0.75f), content.length() - 3, content.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
//                holder.tvPrice.setText(spannableString);
//            } else {
//                Utils.set_price_style2(holder.tvPrice, "¥ " + shProductsBean.getSh_price());
//            }

            holder.tvTitle.setText(shProductsBean.getSh_name());
//            View v_divide = view.findViewById(R.id.v_divide);
//            if (i == 0) {
//                v_divide.setVisibility(View.GONE);
//            } else {
//                v_divide.setVisibility(View.VISIBLE);
//            }
//sku显示(分普通商品显示和话费充值商品显示)
            if ("1".equals(shProductsBean.getSh_biz_type())) {
                holder.llSkuContainer.setVisibility(View.VISIBLE);
                holder.tvSkus.setVisibility(View.GONE);
                List<OrderDetailBean.DataBean.ShProductsBean.ShPropertyBean> sh_property = shProductsBean.getSh_property();
                if (sh_property != null && sh_property.size() > 0) {
                    holder.llSkuContainer.setVisibility(View.VISIBLE);
                    holder.llSkuContainer.removeAllViews();
                    for (OrderDetailBean.DataBean.ShProductsBean.ShPropertyBean propertyBean : sh_property) {
                        View viewSku = View.inflate(mContext, R.layout.item_sku_info, null);
                        TextView tvSkus = viewSku.findViewById(R.id.tv_skus);
                        tvSkus.setText(propertyBean.getSh_attribute_label() + ":" + propertyBean.getSh_alias_name());
                        holder.llSkuContainer.addView(viewSku);
                    }
                } else {
                    holder.llSkuContainer.setVisibility(View.GONE);
                }
            } else {
                holder.llSkuContainer.setVisibility(View.GONE);
                holder.tvSkus.setVisibility(View.VISIBLE);
                String skus = "";
                List<OrderDetailBean.DataBean.ShProductsBean.ShPropertyBean> sh_property = shProductsBean.getSh_property();
                for (OrderDetailBean.DataBean.ShProductsBean.ShPropertyBean propertyBean : sh_property) {
                    skus += ("“" + propertyBean.getSh_alias_name() + "”");
                }
                holder.tvSkus.setText("规格：" + skus);
            }

            if (!"3".equals(dataBean.getSh_order_type())){
                view.setOnClickListener(v -> {
                    if ("purchase".equals(fromType)){
                        ARouter.getInstance().build(AroutePath.PURCHASE_PRODUCT_DETAIL_ACTIVITY)
                                .withString("product_id",shProductsBean.getSh_product_main_id())
                                .navigation();
                    }else {
                        startActivitry(NewCommodityDetailActivity.class, new String[][]{{"id", shProductsBean.getSh_product_main_id()}, {"source_page", "订单详情"}});
                    }
                });
            }

            holder.tvApplyAftersale.setVisibility("1".equals(shProductsBean.getSh_is_refund_btn()) ? View.VISIBLE : View.GONE);
            holder.tvApplyAftersale.setText(shProductsBean.getSh_is_refund_btn_txt());
//            if ("1".equals(shProductsBean.getSh_is_refund_btn())) {
//            if ("1".equals(shProductsBean.getSh_is_refund())) {
//                holder.tvApplyAftersale.setVisibility(View.VISIBLE);
//            } else if ("0".equals(shProductsBean.getSh_is_refund())) {
//                if (!"0".equals(shProductsBean.getSh_aftersale_status())) {
//                    holder.tvInAftersale.setVisibility(View.VISIBLE);
//                    holder.tvInAftersale.setText(shProductsBean.getSh_aftersale_status_desc());
//                }
//            }
//            }

            holder.tvApplyAftersale.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if("1".equals(shProductsBean.getSh_is_refund())){
                        applyType = "product";
                        productsBean = shProductsBean;
                        mPresenter.checkRefund("",shProductsBean.getSh_order_product_id(),progressLoginDialog);
                    }else {
                        checkApplyOfProduct(shProductsBean);
                    }
//                    if ("2".equals(Config.FROZEN)) {
//                        FrozenDialog.showFrozen(mContext);
//                        return;
//                    }
                }
            });
            //赠品列表
            LinearLayout ll_shop_present = (LinearLayout) view.findViewById(R.id.ll_shop_present);
            LinearLayout ll_shop_present_container = (LinearLayout) view.findViewById(R.id.ll_shop_present_container);
            if (shProductsBean.getSh_promotion() != null && shProductsBean.getSh_promotion().size() > 0) {
                ll_shop_present.setVisibility(View.VISIBLE);
                ll_shop_present_container.setVisibility(View.VISIBLE);
                ll_shop_present_container.removeAllViews();
                for (PromotionBean promotionBean : shProductsBean.getSh_promotion()) {
                    View view_present_goods = View.inflate(mContext, R.layout.item_present, null);
                    ImageView ivPresentGood = view_present_goods.findViewById(R.id.iv_good);
                    TextView tvPresentTitle = view_present_goods.findViewById(R.id.tv_title);
                    TextView tvPresentSkus = view_present_goods.findViewById(R.id.tv_skus);
                    TextView tvPresentPrice = view_present_goods.findViewById(R.id.tv_price);
                    TextView tvPresentNum = view_present_goods.findViewById(R.id.tv_num);
                    view_present_goods.setOnClickListener(view1 -> {
                        if (promotionBean.shType != null) {
                            CommonUtil.goAnyWhere(mContext, promotionBean.shType, promotionBean.shTargetId, "", "", "");
                        }
                    });

                    GlideUtil.displayRoundImage(mContext, promotionBean.shProductImg, ivPresentGood, 4, R.mipmap.defaults);
                    tvPresentTitle.setText(promotionBean.shName);
                    String skuStr = "";
                    for (String sku : promotionBean.shSku) {
                        skuStr = skuStr + sku;
                    }
                    tvPresentSkus.setText(skuStr);
                    tvPresentPrice.setText("¥" + promotionBean.shPrice);
                    tvPresentNum.setText("x" + promotionBean.shQty);
                    ll_shop_present_container.addView(view_present_goods);
                }
            } else {
                ll_shop_present.setVisibility(View.GONE);
                ll_shop_present_container.setVisibility(View.GONE);
            }
            llShopContainer.addView(view);
        }

    }

    private void checkApplyOfProduct(OrderDetailBean.DataBean.ShProductsBean shProductsBean){
        if ("1".equals(shProductsBean.getSh_is_refund())) {
            if ("4".equals(dataBean.getSh_type()) && (TextUtils.isEmpty(UserDataManager.getInstance().getRoleLevel()) || Integer.parseInt(UserDataManager.getInstance().getRoleLevel()) < 20)) {
                refundDialog = new ConfirmDialog(OrderDetailActivity.this, "退礼包会失去会员权益，待结算的金额也将冻结不返还，确认退礼包？"
                        , "取消", "确认");
                refundDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                    @Override
                    public void cancel() {
                        refundDialog.dismiss();
                    }

                    @Override
                    public void confirm() {
                        refundDialog.dismiss();
                        intentType(shProductsBean.getSh_order_product_id(),dataBean.getSh_id(),productsBean.getSh_refund_type_arr());
                    }
                });
                refundDialog.show();
            } else {
                intentType(shProductsBean.getSh_order_product_id(),dataBean.getSh_id(),productsBean.getSh_refund_type_arr());
            }
        } else {
            if (TextUtils.isEmpty(shProductsBean.getSh_is_refund_tips())) {
                if ("purchase".equals(fromType)){
                    ARouter.getInstance().build(AroutePath.AFTER_SALE_PURCHASE_DETAIL_ACTIVITY)
                            .withString("order_product_id",shProductsBean.getSh_order_product_id())
                            .withString("order_id", dataBean.getSh_id()).navigation();
                }else {
                    startActivitry(AfterSaleDetailActivity.class, new String[][]{{"product_id", shProductsBean.getSh_order_product_id()}, {"order_id", dataBean.getSh_id()}});
                }
            } else {
                dialog = new ConfirmDialog(OrderDetailActivity.this, shProductsBean.getSh_is_refund_tips()
                        , "取消", "确认", 1,"purchase".equals(fromType)?"#FF6809":"");
                dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                    @Override
                    public void cancel() {
                        dialog.dismiss();
                    }

                    @Override
                    public void confirm() {
                        dialog.dismiss();
                    }
                });
                dialog.show();
            }
        }
    }

    @Override
    public void getCheckRefund(CheckRefundBean dataBean) {
        progressLoginDialog.dismiss();
        if (dataBean != null && dataBean.data != null && !TextUtils.isEmpty(dataBean.data.message)){
            if (dataBean.data.canContinue){
                ConfirmDialog confirmDialog = new ConfirmDialog(OrderDetailActivity.this,true, dataBean.data.message,dataBean.data.title,
                        dataBean.data.prizeName, "继续申请", "再想想");
                confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                    @Override
                    public void cancel() {
                        confirmDialog.dismiss();
                        if ("shop".equals(applyType)){
                            checkApply();
                        }else {
                            checkApplyOfProduct(productsBean);
                        }
                    }

                    @Override
                    public void confirm() {
                        confirmDialog.dismiss();
                    }
                });
                confirmDialog.show();
            }else {
                ConfirmDialog confirmDialog = new ConfirmDialog(OrderDetailActivity.this,
                        dataBean.data.title,dataBean.data.message, "", "确定",1);
                confirmDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                    @Override
                    public void cancel() {
                    }

                    @Override
                    public void confirm() {
                        confirmDialog.dismiss();
                    }
                });
                confirmDialog.show();
            }
        }else {
            if ("shop".equals(applyType)){
                checkApply();
            }else {
                checkApplyOfProduct(productsBean);
            }
        }
    }

    private void intentType(String product_id, String order_id,List<Integer> refundTypeArr){
        if (refundTypeArr == null) return;
        if (refundTypeArr.size()==1){
            if (refundTypeArr.get(0) == 0){
                startActivitry(ReturnMoneyActivity.class, new String[][]{{"product_id", product_id}, {"order_id", order_id}, {"update", "0"},{"from_type",fromType}});
            }else if (refundTypeArr.get(0) == 2){
                ARouter.getInstance().build(AroutePath.RETURN_REDELIVER_ACTIVITY)
                        .withString("product_id", product_id)
                        .withString("update", "0")
                        .withString("from_type",fromType)
                        .withString("order_id", order_id).navigation();
            }else if (refundTypeArr.get(0) == 3){
                startActivitry(ReturnGoodsActivity.class, new String[][]{{"product_id", product_id}, {"order_id", order_id},
                        {"update", "0"},{"from_type",fromType},{"refund_type","dispatched"}});
            }
        }else if (refundTypeArr.size()>1){
            Intent intent = new Intent(this, ChooseAfterSaleActivity.class);
            intent.putExtra("product_id", product_id);
            intent.putExtra("order_id", order_id);
            intent.putExtra("update", "0");
            intent.putExtra("from_type",fromType);
            intent.putExtra("show_list",(ArrayList<Integer>) refundTypeArr);
            startActivity(intent);
        }
    }

    @OnClick({ R.id.tv_current_order, R.id.tv_apply_aftersale, R.id.rl_back, R.id.rl_message,
            R.id.ll_shop, R.id.tv_copy, R.id.contact_seller,R.id.fl_custody_order,R.id.layout_pick_good_order})
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.layout_pick_good_order:
                ARouter.getInstance().build(AroutePath.SALE_ORDER_DETAIL_ACTIVITY)
                        .withString("order_no", dataBean.getSh_order_relation_no()).navigation();
                break;
            case R.id.fl_custody_order:
                ARouter.getInstance().build(AroutePath.STORAGE_ORDER_DETAIL_ACTIVITY)
                        .withString("order_no",order_no).navigation();
                break;
            case R.id.tv_current_order:
                if (dataBean != null && !TextUtils.isEmpty(dataBean.getSh_parent_order_no())) {
                    Intent intent = new Intent(this, OrderDetailActivity.class);
                    intent.putExtra("order_no", dataBean.getSh_parent_order_no());
                    startActivity(intent);
                }
                break;
            case R.id.tv_apply_aftersale:
//                if ("2".equals(Config.FROZEN)) {
//                    FrozenDialog.showFrozen(mContext);
//                    return;
//                }
                if ("1".equals(dataBean.getSh_refund_button().getSh_is_refund())){
                    applyType = "shop";
                    progressLoginDialog.show();
                    progressLoginDialog.setDesc("正在加载...");
                    mPresenter.checkRefund(dataBean.getSh_id(),"",progressLoginDialog);
                } else {
                    checkApply();
                }
                break;
            case R.id.tv_copy:
                ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                // 将文本内容放到系统剪贴板里。
                cm.setPrimaryClip(ClipData.newPlainText(null, order_no));
                showToast("已复制到粘贴板");
                break;
            case R.id.rl_back:
                finish();
                break;
            case R.id.rl_message:
                Information info = SobotManager.getBaseInfo();
                SobotApi.setChatTitleDisplayMode(mContext, SobotChatTitleDisplayMode.Default, "");
                if (dataBean != null) {
                    Map<String, String> customInfo = new HashMap<String, String>();
                    customInfo.put("order_no", dataBean.getSh_order_no());
                    customInfo.put("order_status", dataBean.getSh_status());
                    info.setCustomInfo(customInfo);
                    set_order_card(info);
                }
                //订单卡片

                SobotApi.startSobotChat(OrderDetailActivity.this, info);

                break;
//            case R.id.ll_shop:
//                if (dataBean == null || dataBean.getSh_seller() == null ||
//                        TextUtils.isEmpty(dataBean.getSh_seller().getSh_id()) || dataBean.getSh_order_type() == null ||
//                        "3".equals(dataBean.getSh_order_type()) || !dataBean.getSh_seller().isSh_is_jump())
//                    return;
//
//                    ARouter.getInstance().build(AroutePath.STORE_ACTIVITY)
//                            .withString("is_dealer", dataBean.getSh_seller().isSh_is_dealer()?"1":"0")
//                            .withString("is_agent", dataBean.getSh_seller().isSh_is_agent()?"1":"0")
//                            .withString("store_id", dataBean.getSh_seller().getSh_id()).navigation();
//                break;
////
//            case R.id.contact_seller:
//                if (dataBean.getSh_seller()!=null&&!TextUtils.isEmpty(dataBean.getSh_seller().getSh_mobile())){
//                    ConfirmDialog dialog = new ConfirmDialog(this,"是否拨打电话",null,dataBean.getSh_seller().getSh_mobile(),"取消","确定","#FF6809");
//                    dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
//                        @Override
//                        public void cancel() {
//                            dialog.dismiss();
//                        }
//
//                        @Override
//                        public void confirm() {
//                            IntentUtil.toPhoneApp(OrderDetailActivity.this,dataBean.getSh_seller().getSh_mobile());
//                            dialog.dismiss();
//                        }
//                    });
//                    dialog.show();
//                }else {
//                    Information info_seller = SobotManager.getBaseInfo();
//                    SobotApi.setChatTitleDisplayMode(mContext, SobotChatTitleDisplayMode.Default, "");
//                    if (!TextUtils.isEmpty(sh_sobot_app_key)) {
//                        info_seller.setAppkey(sh_sobot_app_key);
//                        //info_seller.setInitModeType(4);
//                        SobotManager.setSobotFlow(mContext, sh_sobot_flow_company_id, sh_sobot_flow_group_id, "0");
//                    }
//                    if (dataBean != null) {
//                        Map<String, String> customInfo = new HashMap<String, String>();
//                        customInfo.put("order_no", dataBean.getSh_order_no());
//                        customInfo.put("order_status", dataBean.getSh_status());
//                        info_seller.setCustomInfo(customInfo);
//                        set_order_card(info_seller);
//                    }
//                    SobotApi.startSobotChat(OrderDetailActivity.this, info_seller);
//                }
//                break;
        }
    }


    private void checkApply(){
        if ("1".equals(dataBean.getSh_refund_button().getSh_is_refund())) {
            if ("4".equals(dataBean.getSh_type()) && (TextUtils.isEmpty(UserDataManager.getInstance().getRoleLevel()) || Integer.parseInt(UserDataManager.getInstance().getRoleLevel()) < 20)) {
                refundDialog = new ConfirmDialog(OrderDetailActivity.this, "退礼包会失去会员权益，待结算的金额也将冻结不返还，确认退礼包？"
                        , "取消", "确认");
                refundDialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                    @Override
                    public void cancel() {
                        refundDialog.dismiss();
                    }

                    @Override
                    public void confirm() {
                        refundDialog.dismiss();
                        intentType("0",dataBean.getSh_id(),dataBean.getSh_refund_button().getSh_refund_type_arr());
                    }
                });
                refundDialog.show();
            } else {
                intentType("0",dataBean.getSh_id(),dataBean.getSh_refund_button().getSh_refund_type_arr());
            }
        } else {
            if (TextUtils.isEmpty(dataBean.getSh_refund_button().getSh_is_refund_tips())) {
                if ("purchase".equals(fromType)){
                    ARouter.getInstance().build(AroutePath.AFTER_SALE_PURCHASE_DETAIL_ACTIVITY)
                            .withString("order_product_id","0")
                            .withString("order_id", dataBean.getSh_id()).navigation();
                }else {
                    startActivitry(AfterSaleDetailActivity.class, new String[][]{{"product_id", "0"}, {"order_id", dataBean.getSh_id()}});
                }
            } else {
                dialog = new ConfirmDialog(OrderDetailActivity.this, dataBean.getSh_refund_button().getSh_is_refund_tips()
                        , "取消", "确认", 1,"purchase".equals(fromType)?"#FF6809":"");
                dialog.setOnChooseListerner(new ConfirmDialog.OnChooseListerner() {
                    @Override
                    public void cancel() {
                        dialog.dismiss();
                    }

                    @Override
                    public void confirm() {
                        dialog.dismiss();
                    }
                });
                dialog.show();
            }
        }
    }

    private void set_order_card(Information info) {
        int totalFee = (int) Float.valueOf(dataBean.getSh_should_pay_price()).floatValue();
        String productName = "";
        String productImageeUrl = "";
        if (dataBean.getSh_products().size() > 0) {
            productName = dataBean.getSh_products().get(0).getSh_name();
            productImageeUrl = dataBean.getSh_products().get(0).getSh_image();
        }
        SobotManager.setOrderCardInfo(info, dataBean.getSh_order_no(), dataBean.getSh_status(), totalFee, dataBean.getSh_product_num(), dataBean.getSh_create_at(), productName, productImageeUrl);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (resultCode) {
            case ChooseAfterSaleActivity.RESULT_SUCCESS:
                finish();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        rxBus.unregister(Config.MSG_UNREAD);
        super.onDestroy();
        if (timer != null) timer.cancel();
    }

    static class ViewHolder {
        @BindView(R.id.iv_good)
        ImageView ivGood;
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_skus)
        TextView tvSkus;
        @BindView(R.id.ll_sku_container)
        LinearLayout llSkuContainer;
        @BindView(R.id.ll_price)
        PriceIntegralLayout llPrice;
        @BindView(R.id.tag_price_vip)
        TextView tagPriceVip;
        @BindView(R.id.tv_gos_num)
        TextView tvGosNum;
        @BindView(R.id.tv_apply_aftersale)
        TextView tvApplyAftersale;
        @BindView(R.id.layout_price)
        View layoutPrice;
        @BindView(R.id.tv_pick_good_num)
        TextView tvPickGoodNum;
        @BindView(R.id.layout_good_desc)
        View layoutGoodDesc;
        @BindView(R.id.tv_good_desc)
        TextView tvGoodDesc;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
